import requests


class SendMethod:
    @staticmethod
    def send_method(method, url, params=None, body=None):
        if method == "get":
            response = requests.get(url, params=params)
        elif method == "post":
            response = requests.post(url, data=body)
        else:
            response = None
            print("请求方式错误")
        result = {}
        if response is not None:
            result["status_code"] = response.status_code
            result["body"] = response.json()
            return result
        else:
            return response


if __name__ == '__main__':
    # url = "http://127.0.0.1:8000/api/add_event/"
    url="http://127.0.0.1:8000/api/get_event_list/"
    body = {
        "eid": "123456",
        "name": "魅族发布会99p",
        "limit": "20",
        "status": "1",
        "address": "武汉源码时代",
        "start_time": "2022-07-21"
    }
    params={
        "eid":"123456"
    }
    # sm = SendMethod.send_method("post", url=url, body=body)
    sm = SendMethod.send_method("get",url=url,params=params)
    print(sm)
